package com.hedl.practice.diyJava.io.study_outputstream.practice;

import java.io.*;

public class StudyInputStreamAndOutputStream {
    public static void main(String[] args) throws IOException {
        //这个是不可转型字符串的
        try(InputStream input = new FileInputStream("/Users/a101/idea/book.txt");
            OutputStream output = new FileOutputStream("/Users/a101/idea/Hello.txt")){
            String a = inputRead(input);
            output.write(a.getBytes("UTF-8"));

        }
    }

    static String inputRead(InputStream input) throws IOException {
        int n;
        StringBuilder sb = new StringBuilder();
        while((n = input.read()) != -1){
            sb.append((char) n);
        }
        return sb.toString();
    }
}
